Fix caret can disappear from script editor on Windows #93976
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #92821
Also probably fixes #92634 but did not find a way to reproduce more than once.
This was not easy to reproduce! To reproduce I did Alt-Tab while resizing the editor windows. And even then, it takes multiple retries to reproduce the problem.
I’m pretty certain that the problem came from a situation where a new
SetTimer
was called before the timer was actually triggered resulting in a situation whereactivate_timer_id
andmove_timer_id
had the sametimer_id
. BothSetTimer
foractivate_timer_id
andmove_timer_id
had the samenIDEvent
, so the secondSetTimer
replaced the first timer.Documentation for SetTimer from Microsoft:
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-settimer
With some debug print line, we can see that the activate timer can in some situations be created before the resize is triggered:
I did 2 modifications:
nIDEvent
foractivate_timer_id
to 2.WM_ACTIVATE
is received butactivate_timer_id != 0
, a newSetTimer
is created anyway, replacing the first one. That should prevent the weird case whereactivate_timer_id
was never triggered and resetted.